<script setup lang="ts">
/**
 * @desc ServiceCopyTo
 * @author DragonTeam <https://www.bpmport.com>
 * @since 2024/11/7 13:54
 */

import type { PropType } from 'vue'
import { computed } from 'vue'
import { Send } from 'lucide-vue-next'
import type { BaseNode } from '@/types'
import { copyMessageTypeOptions } from '@/configuration/enums'

defineOptions({ name: 'ServiceCopyTo' })

const $props = defineProps({
  node: {
    type: Object as PropType<BaseNode>,
    required: true,
  },
})
const doEmit = defineEmits(['update:node'])
const vModelNode = computed<BaseNode>({
  get: () => $props.node,
  set: val => doEmit('update:node', val),
})

const messageType = computed<string[]>({
  get: () => vModelNode.value.businessData.messageType as string[],
  set: val => vModelNode.value.businessData.messageType = val,
})
const transferTo = computed<any[]>({
  get: () => vModelNode.value.businessData.transferTo as any[],
  set: val => vModelNode.value.businessData.transferTo = val,
})
const messageContent = computed<string>({
  get: () => vModelNode.value.businessData.messageContent as string,
  set: val => vModelNode.value.businessData.messageContent = val,
})
</script>

<template>
  <a-collapse-item key="ServiceCopyTo">
    <template #header>
      <Send :size="16" />
      抄送任务
    </template>

    <EditItem label="消息类型">
      <a-checkbox-group v-model="messageType" :options="copyMessageTypeOptions" />
    </EditItem>

    <EditItem label="抄送人">
      <user-tag-input v-model:data="transferTo" />
    </EditItem>

    <EditItem label="消息内容">
      <validate-textarea v-model="messageContent" />
    </EditItem>
  </a-collapse-item>
</template>
